<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCompanyTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('company', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name', 100)->default('')->comment('公司名称');
            $table->string('short_name', 50)->default('')->comment('公司简称');
            $table->smallInteger('province_id', false, true)->default(0)->comment('所在省ID');
            $table->string('province_name')->default('')->comment('所在省份名称');
            $table->smallInteger('city_id', false, true)->default(0)->comment('所在市ID');
            $table->string('city_name')->default('')->comment('所在城市名称');
            $table->string('address', 100)->default('')->comment('所在具体地址');
            $table->decimal('lat', 9, 6)->nullable()->default(0)->comment('纬度');
            $table->decimal('lng', 9, 6)->nullable()->default(0)->comment('经度');
            $table->string('tel', 20)->default('')->comment('公司电话');
            $table->string('urgency_tel', 20)->nullable()->default('')->comment('紧急电话');clearstatcache();
            $table->string('email', 100)->nullable()->default('')->comment('邮箱');
            $table->string('web_site', 100)->nullable()->default('')->comment('公司网址');
            $table->string('principal_name', 20)->default('')->comment('负责人姓名');
            $table->string('principal_phone', 20)->nullable()->default('')->comment('负责人电话');
            $table->tinyInteger('status', false, true)->default(1)->comment('状态 1-正常 0-禁用');

            $table->index('name');
            $table->index('city_id');

            $table->timestamps();
            $table->softDeletes();
        });
        \DB::statement("ALTER TABLE `company` comment '公司表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('company');
    }
}
